package com.yyx.app1.main.UI;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.Toast;

import com.yyx.app1.Data.DataInit;
import com.yyx.app1.Data.WebOperation;
import com.yyx.app1.MedicationAssistant_function.UI.MedicationAssistant_Activity_;
import com.yyx.app1.R;
import com.yyx.app1.tool.ImageTool;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;

/**
 * Created by yuexing on 2015/8/26.
 */
@EActivity(R.layout.activity_launcher)
public class Launcher_Activity extends Activity {

    @ViewById
    ImageView iv_homeImage;
    @AfterViews
    public void show()
    {
        iv_homeImage.setImageBitmap(ImageTool.readBitmap(this, R.drawable.home));
        iv_homeImage.setScaleType(ImageView.ScaleType.FIT_XY);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //setContentView(R.layout.activity_launcher);
        super.onCreate(savedInstanceState);
        createSqlist();
        new Handler().postDelayed(r, 3000);
    }

    Runnable r = new Runnable() {
        @Override
        public void run() {
            startActivity(new Intent(Launcher_Activity.this,MedicationAssistant_Activity_.class));
            finish();
        }
    };

    @Background
    public void createSqlist()
    {
        DataInit dataInit = new DataInit(this,false,"cxlin");
        dataInit.DatabaseInit();
//        WebOperation web = new WebOperation();
//
//        if(web.downloadNet("http://desk.zol.com.cn/down/1920x1080_73794.html",new DataInit(this,false,"cxlin").getImagePath()+"/bizhi.jpg"))
//        {
//            Toast.makeText(this,"下载完成",Toast.LENGTH_SHORT).show();
//        }
//        dataInit.Download();
//        dataInit.DeleteAll();
//        dataInit.createTable();
//        dataInit.LoadData();
    }

    @UiThread
    public void shows(String s)
    {
        Toast.makeText(this,s,Toast.LENGTH_LONG).show();
    }


}
